﻿
@{
    ViewData["Title"] = "UptRecreationView";
}
<style type="text/css">
    tr.change:hover {
        background-color: #00FF00
    }
</style>

<script src="~/js/vue.min.js"></script>
<script src="~/js/axios.min.js"></script>
<script src="~/js/qs.min.js"></script>
<link href="~/js/Content/bootstrap.css" rel="stylesheet" />
<h3 style="color:chartreuse">修改娱乐项目</h3>
<hr />
<div class="row" id="mm">
    <table>
        <tr style="height:65px;">
            <td>娱乐项目:</td>
            <td><input id="x1" style="border: 0; border-bottom: 1px solid black; background-color:aquamarine;" type="text" /></td>
        </tr>
        <tr style="height:65px">
            <td>开始时间:</td>
            <td><input id="x2" style="border: 0; border-bottom: 1px solid black; background-color:aquamarine;" type="text" /></td>
        </tr>
        <tr style="height:65px">
            <td style="text-align:right">结束时间:</td>
            <td><input id="x3" style="border: 0; border-bottom: 1px solid black; background-color:aquamarine;" type="text" /></td>
        </tr>
        <tr style="height:65px">
            <td style="text-align:right">负责人:</td>
            <td><input id="x4" style="border: 0; border-bottom: 1px solid black; background-color:aquamarine;" type="text" /></td>
        </tr>
        <tr style="height:65px">
            <td style="text-align:right">状态:</td>
            <td><input id="x5" style="border: 0; border-bottom: 1px solid black; background-color:aquamarine;" type="text" /></td>
        </tr>
        <tr style="height:65px;">
            <td colspan="2" style="text-align:center">
                <input v-on:click="addHob" style="width:60px;color:forestgreen;background-color:burlywood;border:1px solid;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:5px" type="button" value="提交" />
                <input v-on:click="AddHob" style="width:60px;color:forestgreen;background-color:burlywood;border:1px solid;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:5px" type="button" value="添加" />
            </td>

        </tr>
    </table>
    <table class="table table-bordered" style="width:600px;margin: auto;margin-top:10px">
        <tr style="background-color:cadetblue;text-align:center">
            <td>编号</td>
            <td>娱乐项目</td>
            <td>收费标准</td>
            <td>备注</td>
            <td>操作</td>
        </tr>
        <tr class="change" v-for="item in users" style="text-align:center">
            <td>{{item.aid}}</td>
            <td>{{item.aname}}</td>
            <td><span style="color:red">￥{{item.aprice}}.00</span>元/小时</td>
            <td>{{item.acomment}}</td>
            <td> <input type="button" style="width: 80px; color:black; background-color:aqua; border: 1px solid; -webkit-border-radius: 15px; -moz-border-radius: 15px; border-radius: 5px" v-on:click="DelRecrea(item.aid)" value="删除" /></td>
        </tr>
    </table>
</div>
<script>
    new Vue({
        el: '#mm',
        data() {
            return {
                users: [],

            }
        },
        mounted: function () {//页面加载成功事件
            this.id = location.search.substring(location.search.indexOf("=") + 1);
            axios
                .get("/Recreation/Recreation", {
                    params: {
                        id: this.id
                    }
                })
                .then(function (i) {
                    $("#x1").val(i.data.rname);
                    $("#x2").val(i.data.rkaiTime);
                    $("#x3").val(i.data.rjieTime);
                    $("#x4").val(i.data.rprincipal);
                    $("#x5").val(i.data.rstate);
                }),
            axios
                .get("/Recreation/AmusementShow")
                .then(res => (this.users = res.data))
        },
        methods: {//修改
            addHob: function () {
                this.id = location.search.substring(location.search.indexOf("=") + 1);
                var m = {}
                m.Rname = $("#x1").val();
                m.RkaiTime = $("#x2").val();
                m.RjieTime = $("#x3").val();
                m.Rprincipal = $("#x4").val();
                m.Rstate = $("#x5").val();
                axios
                    .post("/Recreation/UptRecreation", window.Qs.stringify(m))
                    .then(
                        function (i) {
                            if (i.data > 0) {
                                alert("修改成功");
                                location.href = '/Recreation/RecreationShows';
                            }
                            else {
                                alert("修改失败");
                            }
                        }

                    )
       },//添加
            AddHob: function () {
                var m = {}
                m.Rname = $("#x1").val();
                m.RkaiTime = $("#x2").val();
                m.RjieTime = $("#x3").val();
                m.Rprincipal = $("#x4").val();
                m.Rstate = $("#x5").val();
                axios
                    .post("/Recreation/AddRecren", window.Qs.stringify(m))
                    .then(
                        function (i) {
                            if (i.data > 0) {
                                alert("添加成功");
                                location.href = '/Recreation/RecreationShows';
                            }
                            else {
                                alert("添加失败");
                            }
                        }

                    )
            },
            //删除的方法
            DelRecrea: function (rid) {
                this.id = rid;
                axios
                    .get("/Recreation/Delam", {
                        params: {
                            id: this.id
                        }
                    })
                    .then(
                        function (i) {
                            if (i.data > 0) {
                                alert("删除成功！");
                                location.href = '/Recreation/AddAmusementview'
                            }
                            else {
                                alert("删除失败");
                            }
                        }
                    );

            }

        }

    })
   

</script>


